<%= render 'organizations/organization_invitation_banner' %>

<div class="site-content">
  <div class="site-content-cap">
    <h2 class="site-content-heading">
      <span class="assignment-icon assignment-icon-group">
        <%= octicon 'organization', height: 22 %>
      </span>
      Accept the <strong><%= group_assignment.title %></strong> assignment
    </h2>
  </div>
</div>

<div class="site-content-body">
  <div class="markdown-body">
    <p>Accepting this assignment will give your team access to the assignment repository in the <%= link_to "@#{organization.github_organization.login}", organization.github_organization.html_url %> organization on GitHub.</p>
    <p>Please be certain that the team you are selecting is the correct team as you cannot change this later</p>
  </div>

  <% if @groups.present? %>
    <hr>

    <div class="markdown-body">
      <p><label>Join an existing team</label></p>
    </div>
    <div class="team-grid">
      <div class="columns">
        <div class="one-half team-left">
          <% @group_assignment.group_assignment_repos.each do |group_assignment_repo| %>
              <% if cycle('odd', 'even') == 'odd' %>
                <%= render partial: 'group_assignment_team', locals: { group_assignment_repo: group_assignment_repo } %>
              <% end %>
          <% end %>
        </div>
        <% reset_cycle %>
        <div class="one-half team-right">
          <% @group_assignment.group_assignment_repos.each do |group_assignment_repo| %>
              <% if cycle('odd', 'even') == 'even' %>
                <%= render partial: 'group_assignment_team', locals: { group_assignment_repo: group_assignment_repo } %>
              <% end %>
          <% end %>
        </div>
      </div>

      <div style="clear:both"></div>
    </div>
  <% end %>

  <hr>

  <%= form_tag({ controller: :group_assignment_invitations, action: :accept_invitation}, method: :patch) do %>
    <dl class="form">
      <dt><label><%= 'OR' if @groups.present? %> Create a new team</label></dt>
      <dd class="d-flex">
        <%= text_field_tag 'group[title]', nil, placeholder: 'Create a new team', class: 'form-control input-block' %>
        <%= button_tag(type: 'submit', class: 'btn btn-primary js-navigation js-form-submit') do %>
          <%= octicon 'plus' %> Create team
        <% end %>
      </dd>
    </dl>
  <% end %>
</div>
